package com.digitalchina.lxnsy.api;

import android.app.Activity;
import android.os.Handler;

import com.digitalchina.lxnsy.constant.MSG;
import com.digitalchina.lxnsy.constant.URL;
import com.digitalchina.lxnsy.toolkit.OkHttpUtil;
import com.digitalchina.lxnsy.xml.UserXML;
import com.lzy.okhttputils.model.HttpParams;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.api
 * 创建人：郑皓
 * 创建时间：2018/10/12 11:01
 * 修改备注：
 * ================================================
 */
public class BusinessConsult {

    /**
     * 获取共享商品咨询列表
     *
     * @param activity
     * @param productId 产品id
     * @param page
     * @param limit
     * @param handler
     */
    public static void consultList(Activity activity, String productId, int page, int limit, Handler handler) {
        HttpParams params = new HttpParams();
        params.put("productId", productId);
        params.put("page", String.valueOf(page));
        params.put("limit", String.valueOf(limit));

        OkHttpUtil.post(activity, URL.URL_CONSULT_LIST, "", params, handler,
                MSG.MSG_CONSULT_LIST_SUCCESS, MSG.MSG_CONSULT_LIST_FIELD);
    }

    /**
     * 获取共享商品咨询分类
     *
     * @param activity
     * @param handler
     */
    public static void consultType(Activity activity, Handler handler) {
        HttpParams params = new HttpParams();

        OkHttpUtil.post(activity, URL.URL_CONSULT_TYPE, "", params, handler,
                MSG.MSG_CONSULT_TYPE_SUCCESS, MSG.MSG_CONSULT_TYPE_FIELD);
    }

    /**
     * 提交咨询
     *
     * @param activity
     * @param productId            产品id
     * @param type                 类型   1-共享产品咨询
     * @param consultationTypeCode 共享产品咨询类型code
     * @param consultContent       咨询内容
     * @param replyMen             回复人userAccId
     * @param handler
     */
    public static void saveConsult(Activity activity, String productId, String type, String consultationTypeCode, String consultContent,
                                   String replyMen, String pictures, Handler handler) {
        HttpParams params = new HttpParams();
        params.put("productId", productId);
        params.put("type", type);
        params.put("consultationTypeCode", consultationTypeCode);
        params.put("consultContent", consultContent);
        params.put("consultMen", UserXML.getUserId(activity));
        params.put("replyMen", replyMen);
        params.put("pictures", pictures);

        OkHttpUtil.post(activity, URL.URL_SAVE_CONSULT, "", params, handler,
                MSG.MSG_SAVE_CONSULT_SUCCESS, MSG.MSG_SAVE_CONSULT_FIELD);
    }


    /**
     * 我的咨询列表
     *
     * @param activity
     * @param page
     * @param limit
     * @param handler
     */
    public static void myConsultList(Activity activity, int page, int limit, Handler handler) {
        HttpParams params = new HttpParams();
        params.put("user", UserXML.getUserId(activity));
        params.put("page", String.valueOf(page));
        params.put("limit", String.valueOf(limit));

        OkHttpUtil.post(activity, URL.URL_GET_MY_CONSULT, "", params, handler,
                MSG.MSG_GET_MY_CONSULT_SUCCESS, MSG.MSG_GET_MY_CONSULT_FIELD);
    }

    /**
     * 我的回复列表
     *
     * @param activity
     * @param page
     * @param limit
     * @param handler
     */
    public static void myReplyList(Activity activity, int page, int limit, Handler handler) {
        HttpParams params = new HttpParams();
        params.put("user", UserXML.getUserId(activity));
        params.put("page", String.valueOf(page));
        params.put("limit", String.valueOf(limit));

        OkHttpUtil.post(activity, URL.URL_GET_MY_REPLY, "", params, handler,
                MSG.MSG_GET_MY_REPLY_SUCCESS, MSG.MSG_GET_MY_REPLY_FIELD);
    }

    /**
     * 回复咨询
     *
     * @param activity
     * @param id
     * @param replyContent
     * @param handler
     */
    public static void reply(Activity activity, String id, String replyContent, Handler handler) {
        HttpParams params = new HttpParams();
        params.put("id", id);
        params.put("replyContent", replyContent);

        OkHttpUtil.post(activity, URL.URL_REPLY, "", params, handler,
                MSG.MSG_REPLY_SUCCESS, MSG.MSG_REPLY_FIELD);
    }
}
